<?php

/**
 * Candidate form.
 *
 * @package    lomejorde
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CandidateBackendForm extends BaseCandidateForm
{
    public function configure()
    {
        unset (
            $this['created_at'],$this['updated_at'], $this['nominated_list']
        );
        
        $this->validatorSchema['name']->setOptions(array('required' => true));
        $this->validatorSchema['name']->setMessages(array('required' => 'Campo requerido.'));
        
        $this->setWidget('thumb', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->thumb,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));
        
        $this->setValidator('thumb', new sfValidatorFile(array(
            'mime_types' => 'web_images',
            'path' => sfConfig::get('sf_upload_dir'),
            'required' => false,
        )));
        
        $this->setWidget('image', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->image,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));
        
        $this->setValidator('image', new sfValidatorFile(array(
            'mime_types' => 'web_images',
            'path' => sfConfig::get('sf_upload_dir'),
            'required' => false,
        )));
        
        $this->setValidator('email', new sfValidatorEmail(array('required' => false)));
        
        $this->validatorSchema['email']->setMessages(array('invalid' => 'Correo Electrónico inválido.'));
        
        $this->setWidget('categories_list', new sfWidgetFormDoctrineChoice(array('multiple' => true, 'expanded' => true, 'model' => 'Category')));
        
        $this->widgetSchema->setLabels(array(
            'name'          => 'Nombre',
            'description'   => 'Descripción',
            'thumb'         => 'Thumbnail',
            'image'         => 'Imagen',
            'email'         => 'Correo Electrónico',
            'address'       => 'Dirección',
            'email'         => 'Correo Electrónico',
            'web_page'      => 'Página Web',
            'active'        => 'Activo?',
            'categories_list'   => 'Categorías'
        ));
        
//        $this->widgetSchema['name']->setAttributes(array('class' => 'span-5'));
//        
//        $this->widgetSchema['description']->setAttributes(array('class' => 'span-5'));
//        
//        $this->widgetSchema->setHelp('description','Por ejemplo: Dirección, página Web o una descripción');
//        
//        $this->widgetSchema->setLabels(array(
//            'name' => 'Nombre',
//            'description' => 'Referencia'
//        ));
//        
//        $this->validatorSchema['name']->setMessages(array('required' => 'Campo requerido.'));
//        
//        $this->validatorSchema['description']->setOption('required', true);
//        
//        $this->validatorSchema['description']->setMessages(array('required' => 'Campo requerido.'));
//        
//        $this->widgetSchema->setFormFormatterName('candidate');
    }
}
